#include "arrow.h"


using namespace tp2;

Arrow::Arrow(float sideLong)
{
	m_sideLong = sideLong;

	m_polygonModeFace = GL_FRONT_AND_BACK;
	m_polygonMode =  GL_FILL;
}


Arrow::~Arrow(void)
{
}

void Arrow::Init()
{
	m_idList = glGenLists(1);
	glNewList(m_idList, GL_COMPILE);
		Render();
	glEndList();
}

void Arrow::Render()
{
	glDisable(GL_LIGHTING);

	glPolygonMode(m_polygonModeFace,m_polygonMode);

	//En el plano YZ.
	glBegin(GL_POLYGON);
		glVertex3f(0.0f,0.0f,0);
		glVertex3f(0.0f,m_sideLong/2.0f,m_sideLong/2.0f);
		glVertex3f(0.0f,0.0f,m_sideLong);
	glEnd();

	glEnable(GL_LIGHTING);
}

void Arrow::RenderDL()
{
	glCallList(m_idList);
}

void Arrow::SetPolygonMode(GLenum face, GLenum mode)
{
	m_polygonModeFace = face;
	m_polygonMode = mode;	
}

GLenum Arrow::GetPolygonMode()
{
	return m_polygonMode;
}